<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Unary coding</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Unary_coding"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Unary_coding rootpage-Unary_coding skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Unary coding</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p><b>Unary coding</b>,<sup id="cite_ref-NB1_1-0" class="reference"><a href="#cite_note-NB1-1"><span class="cite-bracket">[</span>nb 1<span class="cite-bracket">]</span></a></sup> or the <a href="Unary_numeral_system" title="Unary numeral system">unary numeral system</a>, is an <a href="Entropy_encoding" class="mw-redirect" title="Entropy encoding">entropy encoding</a> that represents a <a href="Natural_number" title="Natural number">natural number</a>, <i>n</i>, with <i>n</i> ones followed by a zero (if the term <i>natural number</i> is understood as <i>non-negative integer</i>) or with <i>n</i> − 1 ones followed by a zero (if the term <i>natural number</i> is understood as <i>strictly positive integer</i>). A unary number's code length would thus be <i>n</i> + 1 with that first definition, or <i>n</i> with that second definition. Unary code when vertical behaves like mercury in a <a href="Thermometer" title="Thermometer">thermometer</a> that gets taller or shorter as <i>n</i> gets bigger or smaller, and so is sometimes called <b>thermometer code</b>.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> An alternative representation uses <i>n</i> or <i>n</i> − 1 zeros followed by a one, effectively swapping the ones and zeros, <a href="Without_loss_of_generality" title="Without loss of generality">without loss of generality</a>. For example, the first ten unary codes are:
</p>
<table class="wikitable">
<tbody><tr>
<th>Unary code</th>
<th>Alternative
</th>
<th>n (non-negative)
</th>
<th>n (strictly positive)
</th></tr>
<tr>
<td>0</td>
<td>1
</td>
<td>0
</td>
<td>1
</td></tr>
<tr>
<td>10</td>
<td>01
</td>
<td>1
</td>
<td>2
</td></tr>
<tr>
<td>110</td>
<td>001
</td>
<td>2
</td>
<td>3
</td></tr>
<tr>
<td>1110</td>
<td>0001
</td>
<td>3
</td>
<td>4
</td></tr>
<tr>
<td>11110</td>
<td>00001
</td>
<td>4
</td>
<td>5
</td></tr>
<tr>
<td>111110</td>
<td>000001
</td>
<td>5
</td>
<td>6
</td></tr>
<tr>
<td>1111110</td>
<td>0000001
</td>
<td>6
</td>
<td>7
</td></tr>
<tr>
<td>11111110</td>
<td>00000001
</td>
<td>7
</td>
<td>8
</td></tr>
<tr>
<td>111111110</td>
<td>000000001
</td>
<td>8
</td>
<td>9
</td></tr>
<tr>
<td>1111111110</td>
<td>0000000001
</td>
<td>9
</td>
<td>10
</td></tr></tbody></table>
<p>Unary coding is an <i>optimally efficient</i> encoding for the following discrete <a href="Probability_distribution" title="Probability distribution">probability distribution</a>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {P} (n)=2^{-n}\,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">P</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<msup>
<mn>2</mn>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mi>n</mi>
</mrow>
</msup>
<mspace width="thinmathspace"></mspace>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {P} (n)=2^{-n}\,}</annotation>
</semantics>
</math></span><img src="./90ee6bd35485ffd3d7ba2201cd10cc694962f402.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:11.932ex; height:3.009ex;" alt="{\displaystyle \operatorname {P} (n)=2^{-n}\,}" loading="lazy"></span></dd></dl>
<p>for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n=1,2,3,...}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
<mo>=</mo>
<mn>1</mn>
<mo>,</mo>
<mn>2</mn>
<mo>,</mo>
<mn>3</mn>
<mo>,</mo>
<mo>.</mo>
<mo>.</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n=1,2,3,...}</annotation>
</semantics>
</math></span><img src="./795e97703ca4d9a106193e06cc58e4a676609f78.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:13.797ex; height:2.509ex;" alt="{\displaystyle n=1,2,3,...}" loading="lazy"></span>.
</p><p>In symbol-by-symbol coding, it is optimal for any <a href="Geometric_distribution" title="Geometric distribution">geometric distribution</a>
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {P} (n)=(k-1)k^{-n}\,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">P</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>=</mo>
<mo stretchy="false">(</mo>
<mi>k</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<msup>
<mi>k</mi>
<mrow class="MJX-TeXAtom-ORD">
<mo>−<!-- − --></mo>
<mi>n</mi>
</mrow>
</msup>
<mspace width="thinmathspace"></mspace>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {P} (n)=(k-1)k^{-n}\,}</annotation>
</semantics>
</math></span><img src="./772c2ca9aeed73e1de86a320432c64c456d6fb02.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:19.004ex; height:3.009ex;" alt="{\displaystyle \operatorname {P} (n)=(k-1)k^{-n}\,}" loading="lazy"></span></dd></dl>
<p>for which <i>k</i> ≥ φ = 1.61803398879..., the <a href="Golden_ratio" title="Golden ratio">golden ratio</a>, or, more generally, for any discrete distribution for which
</p>
<dl><dd><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {P} (n)\geq \operatorname {P} (n+1)+\operatorname {P} (n+2)\,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi mathvariant="normal">P</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
<mo>≥<!-- ≥ --></mo>
<mi mathvariant="normal">P</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo>+</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo>+</mo>
<mi mathvariant="normal">P</mi>
<mo><!-- --></mo>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mo>+</mo>
<mn>2</mn>
<mo stretchy="false">)</mo>
<mspace width="thinmathspace"></mspace>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {P} (n)\geq \operatorname {P} (n+1)+\operatorname {P} (n+2)\,}</annotation>
</semantics>
</math></span><img src="./7e441bf02f5794f7927fa157d2ee2b05342a071b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:28.692ex; height:2.843ex;" alt="{\displaystyle \operatorname {P} (n)\geq \operatorname {P} (n+1)+\operatorname {P} (n+2)\,}" loading="lazy"></span></dd></dl>
<p>for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle n=1,2,3,...}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>n</mi>
<mo>=</mo>
<mn>1</mn>
<mo>,</mo>
<mn>2</mn>
<mo>,</mo>
<mn>3</mn>
<mo>,</mo>
<mo>.</mo>
<mo>.</mo>
<mo>.</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle n=1,2,3,...}</annotation>
</semantics>
</math></span><img src="./795e97703ca4d9a106193e06cc58e4a676609f78.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:13.797ex; height:2.509ex;" alt="{\displaystyle n=1,2,3,...}" loading="lazy"></span>. Although it is the optimal symbol-by-symbol coding for such probability distributions, <a href="Golomb_coding" title="Golomb coding">Golomb coding</a> achieves better compression capability for the geometric distribution because it does not consider input symbols independently, but rather implicitly groups the inputs. For the same reason, <a href="Arithmetic_encoding" class="mw-redirect" title="Arithmetic encoding">arithmetic encoding</a> performs better for general probability distributions, as in the last case above.
</p><p>Unary coding is both a <a href="Prefix-free_code" class="mw-redirect" title="Prefix-free code">prefix-free code</a> and a <a href="Self-synchronizing_code" title="Self-synchronizing code">self-synchronizing code</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Unary_code_in_use_today">Unary code in use today</h2></div>
<p>Examples of unary code uses include:
</p>
<ul><li>In <a href="Golomb_Rice_code" class="mw-redirect" title="Golomb Rice code">Golomb Rice code</a>, unary encoding is used to encode the quotient part of the Golomb code word.</li>
<li>In <a href="UTF-8" title="UTF-8">UTF-8</a>, unary encoding is used in the leading byte of a multi-byte sequence to indicate the number of bytes in the sequence so that the length of the sequence can be determined without examining the continuation bytes.</li>
<li><a href="Instantaneously_trained_neural_networks" title="Instantaneously trained neural networks">Instantaneously trained neural networks</a> use unary coding for efficient data representation.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Unary_coding_in_biological_networks">Unary coding in biological networks</h2></div>
<p>Unary coding is used in the <a href="Neural_circuit" title="Neural circuit">neural circuits</a> responsible for <a href="Birdsong" class="mw-redirect" title="Birdsong">birdsong</a> production.<sup id="cite_ref-Fiete_2007_3-0" class="reference"><a href="#cite_note-Fiete_2007-3"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Moore_2011_4-0" class="reference"><a href="#cite_note-Moore_2011-4"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> The nucleus in the brain of the songbirds that plays a part in both the learning and the production of bird song is the HVC (<a href="High_vocal_center" class="mw-redirect" title="High vocal center">high vocal center</a>). The command signals for different notes in the birdsong emanate from different points in the HVC. This coding works as space coding which is an efficient strategy for biological circuits due to its inherent simplicity and robustness.
</p>
<div class="mw-heading mw-heading2"><h2 id="Standard_run-length_unary_codes">Standard run-length unary codes</h2></div>
<p>All binary data is defined by the ability to represent unary numbers in alternating run-lengths of 1s and 0s. This conforms to the standard definition of unary i.e. N digits of the same number 1 or 0. All run-lengths by definition have at least one digit and thus represent <i>strictly positive integers</i>.
</p>
<table class="wikitable">
<tbody><tr>
<th>n</th>
<th>RL code</th>
<th>Next code
</th></tr>
<tr>
<td>1</td>
<td>1</td>
<td>0
</td></tr>
<tr>
<td>2</td>
<td>11</td>
<td>00
</td></tr>
<tr>
<td>3</td>
<td>111</td>
<td>000
</td></tr>
<tr>
<td>4</td>
<td>1111</td>
<td>0000
</td></tr>
<tr>
<td>5</td>
<td>11111</td>
<td>00000
</td></tr>
<tr>
<td>6</td>
<td>111111</td>
<td>000000
</td></tr>
<tr>
<td>7</td>
<td>1111111</td>
<td>0000000
</td></tr>
<tr>
<td>8</td>
<td>11111111</td>
<td>00000000
</td></tr>
<tr>
<td>9</td>
<td>111111111</td>
<td>000000000
</td></tr>
<tr>
<td>10</td>
<td>1111111111</td>
<td>0000000000
</td></tr>
<tr>
<td colspan="3">...
</td></tr></tbody></table>
<p>These codes are guaranteed to end validly on any length of data (when reading arbitrary data) and in the (separate) write cycle allow for the use and transmission of an extra bit (the one used for the first bit) while maintaining overall and per-integer unary code lengths of exactly N.
</p>
<div class="mw-heading mw-heading2"><h2 id="Uniquely_decodable_non-prefix_unary_codes">Uniquely decodable non-prefix unary codes</h2></div>
<p>Following is an example of <a href="Uniquely_decodable_code" class="mw-redirect" title="Uniquely decodable code">uniquely decodable</a> unary codes that is not a <a href="Prefix_code" title="Prefix code">prefix code</a> and is not instantaneously decodable (<a rel="nofollow" class="external text" href="http://www.cs.ucf.edu/courses/cap5015/Huff.pdf">need look-ahead to decode</a>)
</p>
<table class="wikitable">
<tbody><tr>
<th>n</th>
<th>Unary code
</th>
<th>Alternative
</th></tr>
<tr>
<td>1</td>
<td>1
</td>
<td>0
</td></tr>
<tr>
<td>2</td>
<td>10
</td>
<td>01
</td></tr>
<tr>
<td>3</td>
<td>100
</td>
<td>011
</td></tr>
<tr>
<td>4</td>
<td>1000
</td>
<td>0111
</td></tr>
<tr>
<td>5</td>
<td>10000
</td>
<td>01111
</td></tr>
<tr>
<td>6</td>
<td>100000
</td>
<td>011111
</td></tr>
<tr>
<td>7</td>
<td>1000000
</td>
<td>0111111
</td></tr>
<tr>
<td>8</td>
<td>10000000
</td>
<td>01111111
</td></tr>
<tr>
<td>9</td>
<td>100000000
</td>
<td>011111111
</td></tr>
<tr>
<td>10</td>
<td>1000000000
</td>
<td>0111111111
</td></tr>
<tr>
<td colspan="3">...
</td></tr></tbody></table>
<p>These codes also (when writing unsigned integers) allow for the use and transmission of an extra bit (the one used for the first bit). Thus they are able to transmit 'm' integers * N unary bits and 1 additional bit of information within m*N bits of data.
</p>
<div class="mw-heading mw-heading2"><h2 id="Symmetric_unary_codes">Symmetric unary codes</h2></div>
<p>The following symmetric unary codes can be read and instantaneously decoded in either direction:
</p>
<table class="wikitable" style="text-align: center;">
<tbody><tr>
<th>Unary code
</th>
<th>Alternative
</th>
<th>n (non-negative)
</th>
<th>n (strictly positive)
</th></tr>
<tr>
<td>1
</td>
<td>0
</td>
<td>0
</td>
<td>1
</td></tr>
<tr>
<td>00
</td>
<td>11
</td>
<td>1
</td>
<td>2
</td></tr>
<tr>
<td>010
</td>
<td>101
</td>
<td>2
</td>
<td>3
</td></tr>
<tr>
<td>0110
</td>
<td>1001
</td>
<td>3
</td>
<td>4
</td></tr>
<tr>
<td>01110
</td>
<td>10001
</td>
<td>4
</td>
<td>5
</td></tr>
<tr>
<td>011110
</td>
<td>100001
</td>
<td>5
</td>
<td>6
</td></tr>
<tr>
<td>0111110
</td>
<td>1000001
</td>
<td>6
</td>
<td>7
</td></tr>
<tr>
<td>01111110
</td>
<td>10000001
</td>
<td>7
</td>
<td>8
</td></tr>
<tr>
<td>011111110
</td>
<td>100000001
</td>
<td>8
</td>
<td>9
</td></tr>
<tr>
<td>0111111110
</td>
<td>1000000001
</td>
<td>9
</td>
<td>10
</td></tr>
<tr>
<td colspan="4">...
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="Canonical_unary_codes">Canonical unary codes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">See also: <a href="Canonical_Huffman_code" title="Canonical Huffman code">Canonical Huffman code</a></div>
<p>For unary values where the maximum is known, one can use canonical unary codes that are of a somewhat numerical nature and different from character based codes. The largest <i>n</i> numerical '0' or '-1' ( <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \operatorname {2} ^{n}-1\,}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mi mathvariant="normal">2</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>n</mi>
</mrow>
</msup>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mspace width="thinmathspace"></mspace>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \operatorname {2} ^{n}-1\,}</annotation>
</semantics>
</math></span><img src="./b1afce31b39a9e25623cc41e4492883c50cf8a23.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.505ex; width:6.126ex; height:2.509ex;" alt="{\displaystyle \operatorname {2} ^{n}-1\,}" loading="lazy"></span>) and the maximum number of digits then for each step reducing the number of digits by one and increasing/decreasing the result by numerical '1'.
</p>
<table class="wikitable">
<tbody><tr>
<th>n</th>
<th>Unary code
</th>
<th>Alternative
</th></tr>
<tr>
<td>1</td>
<td>1
</td>
<td>0
</td></tr>
<tr>
<td>2</td>
<td>01
</td>
<td>10
</td></tr>
<tr>
<td>3</td>
<td>001
</td>
<td>110
</td></tr>
<tr>
<td>4</td>
<td>0001
</td>
<td>1110
</td></tr>
<tr>
<td>5</td>
<td>00001
</td>
<td>11110
</td></tr>
<tr>
<td>6</td>
<td>000001
</td>
<td>111110
</td></tr>
<tr>
<td>7</td>
<td>0000001
</td>
<td>1111110
</td></tr>
<tr>
<td>8</td>
<td>00000001
</td>
<td>11111110
</td></tr>
<tr>
<td>9</td>
<td>000000001
</td>
<td>111111110
</td></tr>
<tr style="color: red;">
<td>10</td>
<td>000000000
</td>
<td>111111111
</td></tr>
<tr>
<td colspan="3">
</td></tr></tbody></table>
<p>Canonical codes can <a rel="nofollow" class="external text" href="http://www.cs.ucf.edu/courses/cap5015/Huff.pdf">require less processing time to decode</a> when they are processed as numbers not a string. If the number of codes required per symbol length is different to 1, i.e. there are more non-unary codes of some length required, those would be achieved by increasing/decreasing the values numerically without reducing the length in that case.
</p>
<div class="mw-heading mw-heading2"><h2 id="Generalized_unary_coding">Generalized unary coding</h2></div>
<p>A generalized version of unary coding was presented by <a href="Subhash_Kak" title="Subhash Kak">Subhash Kak</a> to represent numbers much more efficiently than standard unary coding.<sup id="cite_ref-Kak_2015_5-0" class="reference"><a href="#cite_note-Kak_2015-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> Here's an example of generalized unary coding for integers from 0 through 15 that requires only 7 bits (where three bits are arbitrarily chosen in place of a single one in standard unary to show the number). Note that the representation is cyclic where one uses markers to represent higher integers in higher cycles.
</p>
<table class="wikitable">
<tbody><tr>
<th>n</th>
<th>Unary code</th>
<th>Generalized unary
</th></tr>
<tr>
<td>0</td>
<td>0</td>
<td>0000000
</td></tr>
<tr>
<td>1</td>
<td>10</td>
<td>0000111
</td></tr>
<tr>
<td>2</td>
<td>110</td>
<td>0001110
</td></tr>
<tr>
<td>3</td>
<td>1110</td>
<td>0011100
</td></tr>
<tr>
<td>4</td>
<td>11110</td>
<td>0111000
</td></tr>
<tr>
<td>5</td>
<td>111110</td>
<td>1110000
</td></tr>
<tr>
<td>6</td>
<td>1111110</td>
<td>0010111
</td></tr>
<tr>
<td>7</td>
<td>11111110</td>
<td>0101110
</td></tr>
<tr>
<td>8</td>
<td>111111110</td>
<td>1011100
</td></tr>
<tr>
<td>9</td>
<td>1111111110</td>
<td>0111001
</td></tr>
<tr>
<td>10</td>
<td>11111111110</td>
<td>1110010
</td></tr>
<tr>
<td>11</td>
<td>111111111110</td>
<td>0100111
</td></tr>
<tr>
<td>12</td>
<td>1111111111110</td>
<td>1001110
</td></tr>
<tr>
<td>13</td>
<td>11111111111110</td>
<td>0011101
</td></tr>
<tr>
<td>14</td>
<td>111111111111110</td>
<td>0111010
</td></tr>
<tr>
<td>15</td>
<td>1111111111111110</td>
<td>1110100
</td></tr></tbody></table>
<p>Generalized unary coding requires that the range of numbers to be represented to be pre-specified because this range determines the number of bits that are needed.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Unary_numeral_system" title="Unary numeral system">Unary numeral system</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-NB1-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-NB1_1-0">^</a></b></span> <span class="reference-text">The equivalent to the term "unary coding" in German scientific literature is "<span title="German-language text"><i lang="de">BCD-Zählcode</i></span>", which would translate into "<a href="Binary-coded_decimal" title="Binary-coded decimal">binary-coded decimal</a> counting code". This must not be confused with the similar German term "<span title="German-language text"><i lang="de">BCD-Code</i></span>" translating to <a href="BCD_code" class="mw-redirect" title="BCD code">BCD code</a> in English.</span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.bcp.psych.ualberta.ca/~mike/Pearl_Street/Dictionary/contents/T/thermcode.html">"University of Alberta Dictionary of Cognitive Science: Thermometer Code"</a>. <i>www.bcp.psych.ualberta.ca</i><span class="reference-accessdate">. Retrieved <span class="nowrap">2025-05-31</span></span>.</cite></span>
</li>
<li id="cite_note-Fiete_2007-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-Fiete_2007_3-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFFieteSeung2007" class="citation book cs1">Fiete, I. R.; Seung, H. S. (2007). "Neural network models of birdsong production, learning, and coding". In Squire, L.; Albright, T.; Bloom, F.; Gage, F.; Spitzer, N. (eds.). <i>New Encyclopedia of Neuroscience</i>. <a href="Elsevier" title="Elsevier">Elsevier</a>.</cite></span>
</li>
<li id="cite_note-Moore_2011-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-Moore_2011_4-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFMoore2011" class="citation journal cs1">Moore, J. M.; et al. (2011). <a rel="nofollow" class="external text" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3182746">"Motor pathway convergence predicts syllable repertoire size in oscine birds"</a>. <i>Proc. Natl. Acad. Sci. USA</i>. <b>108</b> (39): <span class="nowrap">16440–</span>16445. <a href="Bibcode_(identifier)" class="mw-redirect" title="Bibcode (identifier)">Bibcode</a>:<a rel="nofollow" class="external text" href="https://ui.adsabs.harvard.edu/abs/2011PNAS..10816440M">2011PNAS..10816440M</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.1073%2Fpnas.1102077108">10.1073/pnas.1102077108</a></span>. <a href="PMC_(identifier)" class="mw-redirect" title="PMC (identifier)">PMC</a> <span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3182746">3182746</a></span>. <a href="PMID_(identifier)" class="mw-redirect" title="PMID (identifier)">PMID</a> <a rel="nofollow" class="external text" href="https://pubmed.ncbi.nlm.nih.gov/21918109">21918109</a>.</cite></span>
</li>
<li id="cite_note-Kak_2015-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-Kak_2015_5-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFKak2015" class="citation journal cs1">Kak, S. (2015). "Generalized unary coding". <i>Circuits, Systems and Signal Processing</i>. <b>35</b> (4): <span class="nowrap">1419–</span>1426. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2Fs00034-015-0120-7">10.1007/s00034-015-0120-7</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:27902257">27902257</a>.</cite></span>
</li>
</ol></div></div>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Data_compression_methods241" style="padding:3px"><table class="nowraplinks hlist mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Data_compression_methods241" style="font-size:114%;margin:0 4em"><a href="Data_compression" title="Data compression">Data compression</a> methods</div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Lossless_compression" title="Lossless compression">Lossless</a><br>type</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Entropy_coding" title="Entropy coding">Entropy</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Adaptive_coding" title="Adaptive coding">Adaptive coding</a></li>
<li><a href="Arithmetic_coding" title="Arithmetic coding">Arithmetic</a></li>
<li><a href="Asymmetric_numeral_systems" title="Asymmetric numeral systems">Asymmetric numeral systems</a></li>
<li><a href="Golomb_coding" title="Golomb coding">Golomb</a></li>
<li><a href="Huffman_coding" title="Huffman coding">Huffman</a>
<ul><li><a href="Adaptive_Huffman_coding" title="Adaptive Huffman coding">Adaptive</a></li>
<li><a href="Canonical_Huffman_code" title="Canonical Huffman code">Canonical</a></li>
<li><a href="Modified_Huffman_coding" title="Modified Huffman coding">Modified</a></li></ul></li>
<li><a href="Range_coding" title="Range coding">Range</a></li>
<li><a href="Shannon_coding" title="Shannon coding">Shannon</a></li>
<li><a href="Shannon%E2%80%93Fano_coding" title="Shannon–Fano coding">Shannon–Fano</a></li>
<li><a href="Shannon%E2%80%93Fano%E2%80%93Elias_coding" title="Shannon–Fano–Elias coding">Shannon–Fano–Elias</a></li>
<li><a href="Tunstall_coding" title="Tunstall coding">Tunstall</a></li>
<li><a href="Universal_code_(data_compression)" title="Universal code (data compression)">Universal</a>
<ul><li><a href="Exponential-Golomb_coding" title="Exponential-Golomb coding">Exp-Golomb</a></li>
<li><a href="Fibonacci_coding" title="Fibonacci coding">Fibonacci</a></li>
<li><a href="Elias_gamma_coding" title="Elias gamma coding">Gamma</a></li>
<li><a href="Levenshtein_coding" title="Levenshtein coding">Levenshtein</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Dictionary_coder" title="Dictionary coder">Dictionary</a></th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Byte-pair_encoding" title="Byte-pair encoding">Byte-pair encoding</a></li>
<li><a href="LZ77_and_LZ78" title="LZ77 and LZ78">Lempel–Ziv</a>
<ul><li><a href="842_(compression_algorithm)" title="842 (compression algorithm)">842</a></li>
<li><a href="LZ4_(compression_algorithm)" title="LZ4 (compression algorithm)">LZ4</a></li>
<li><a href="LZJB" class="mw-redirect" title="LZJB">LZJB</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Oberhumer" title="Lempel–Ziv–Oberhumer">LZO</a></li>
<li><a href="LZRW" title="LZRW">LZRW</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Storer%E2%80%93Szymanski" title="Lempel–Ziv–Storer–Szymanski">LZSS</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Welch" title="Lempel–Ziv–Welch">LZW</a></li>
<li><a href="LZWL" title="LZWL">LZWL</a></li>
<li><a href="Snappy_(compression)" title="Snappy (compression)">Snappy</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Burrows%E2%80%93Wheeler_transform" title="Burrows–Wheeler transform">BWT</a></li>
<li><a href="Context_tree_weighting" title="Context tree weighting">CTW</a></li>
<li><a href="Context_mixing" title="Context mixing">CM</a></li>
<li><a href="Delta_encoding" title="Delta encoding">Delta</a>
<ul><li><a href="Incremental_encoding" title="Incremental encoding">Incremental</a></li></ul></li>
<li><a href="Dynamic_Markov_compression" title="Dynamic Markov compression">DMC</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a></li>
<li><a href="Grammar-based_code" title="Grammar-based code">Grammar</a>
<ul><li><a href="Re-Pair" title="Re-Pair">Re-Pair</a></li>
<li><a href="Sequitur_algorithm" title="Sequitur algorithm">Sequitur</a></li></ul></li>
<li><a href="Discrete_cosine_transform" title="Discrete cosine transform">LDCT</a></li>
<li><a href="Move-to-front_transform" title="Move-to-front transform">MTF</a></li>
<li><a href="PAQ" title="PAQ">PAQ</a></li>
<li><a href="Prediction_by_partial_matching" title="Prediction by partial matching">PPM</a></li>
<li><a href="Run-length_encoding" title="Run-length encoding">RLE</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Hybrid</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li>LZ77 + Huffman
<ul><li><a href="Deflate" title="Deflate">Deflate</a></li>
<li><a href="LZX" title="LZX">LZX</a></li>
<li><a href="Lempel%E2%80%93Ziv%E2%80%93Stac" title="Lempel–Ziv–Stac">LZS</a></li></ul></li>
<li>LZ77 + ANS
<ul><li><a href="LZFSE" title="LZFSE">LZFSE</a></li></ul></li>
<li>LZ77 + Huffman + ANS
<ul><li><a href="Zstd" title="Zstd">Zstandard</a></li></ul></li>
<li>LZ77 + Huffman + context
<ul><li><a href="Brotli" title="Brotli">Brotli</a></li></ul></li>
<li>LZSS + Huffman
<ul><li><a href="LHA_(file_format)" title="LHA (file format)">LHA/LZH</a></li></ul></li>
<li>LZ77 + Range
<ul><li><a href="LZMA" title="LZMA">LZMA</a></li>
<li>LZHAM</li></ul></li>
<li>RLE + BWT + MTF + Huffman
<ul><li><a href="Bzip2" title="Bzip2">bzip2</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Lossy_compression" title="Lossy compression">Lossy</a><br>type</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Transform_coding" title="Transform coding">Transform</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">Discrete cosine transform</a>
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Modified_discrete_cosine_transform" title="Modified discrete cosine transform">MDCT</a></li></ul></li>
<li><a href="Discrete_sine_transform" title="Discrete sine transform">DST</a></li>
<li><a href="Fast_Fourier_transform" title="Fast Fourier transform">FFT</a></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li>
<li><a href="Set_partitioning_in_hierarchical_trees" title="Set partitioning in hierarchical trees">SPIHT</a></li></ul></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Predictive</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a>
<ul><li><a href="Adaptive_differential_pulse-code_modulation" title="Adaptive differential pulse-code modulation">ADPCM</a></li></ul></li>
<li><a href="Linear_predictive_coding" title="Linear predictive coding">LPC</a>
<ul><li><a href="Algebraic_code-excited_linear_prediction" title="Algebraic code-excited linear prediction">ACELP</a></li>
<li><a href="Code-excited_linear_prediction" title="Code-excited linear prediction">CELP</a></li>
<li><a href="Log_area_ratio" title="Log area ratio">LAR</a></li>
<li><a href="Line_spectral_pairs" title="Line spectral pairs">LSP</a></li>
<li><a href="Warped_linear_predictive_coding" title="Warped linear predictive coding">WLPC</a></li></ul></li>
<li>Motion
<ul><li><a href="Motion_compensation" title="Motion compensation">Compensation</a></li>
<li><a href="Motion_estimation" title="Motion estimation">Estimation</a></li>
<li><a href="Motion_vector" class="mw-redirect" title="Motion vector">Vector</a></li></ul></li>
<li><a href="Psychoacoustics" title="Psychoacoustics">Psychoacoustic</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Data_compression#Audio" title="Data compression">Audio</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_rate" title="Bit rate">Bit rate</a>
<ul><li><a href="Average_bitrate" title="Average bitrate">ABR</a></li>
<li><a href="Constant_bitrate" title="Constant bitrate">CBR</a></li>
<li><a href="Variable_bitrate" title="Variable bitrate">VBR</a></li></ul></li>
<li><a href="Companding" title="Companding">Companding</a></li>
<li><a href="Convolution" title="Convolution">Convolution</a></li>
<li><a href="Dynamic_range" title="Dynamic range">Dynamic range</a></li>
<li><a href="Latency_(audio)" title="Latency (audio)">Latency</a></li>
<li><a href="Nyquist%E2%80%93Shannon_sampling_theorem" title="Nyquist–Shannon sampling theorem">Nyquist–Shannon theorem</a></li>
<li><a href="Sampling_(signal_processing)" title="Sampling (signal processing)">Sampling</a></li>
<li><a href="Silence_compression" title="Silence compression">Silence compression</a></li>
<li><a href="Sound_quality" title="Sound quality">Sound quality</a></li>
<li><a href="Speech_coding" title="Speech coding">Speech coding</a></li>
<li><a href="Sub-band_coding" title="Sub-band coding">Sub-band coding</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Audio_codec" title="Audio codec">Codec</a><br>parts</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="A-law_algorithm" title="A-law algorithm">A-law</a></li>
<li><a href="%CE%9C-law_algorithm" title="Μ-law algorithm">μ-law</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a>
<ul><li><a href="Adaptive_differential_pulse-code_modulation" title="Adaptive differential pulse-code modulation">ADPCM</a></li>
<li><a href="Delta_modulation" title="Delta modulation">DM</a></li></ul></li>
<li><a href="Fourier_transform" title="Fourier transform">FT</a>
<ul><li><a href="Fast_Fourier_transform" title="Fast Fourier transform">FFT</a></li></ul></li>
<li><a href="Linear_predictive_coding" title="Linear predictive coding">LPC</a>
<ul><li><a href="Algebraic_code-excited_linear_prediction" title="Algebraic code-excited linear prediction">ACELP</a></li>
<li><a href="Code-excited_linear_prediction" title="Code-excited linear prediction">CELP</a></li>
<li><a href="Log_area_ratio" title="Log area ratio">LAR</a></li>
<li><a href="Line_spectral_pairs" title="Line spectral pairs">LSP</a></li>
<li><a href="Warped_linear_predictive_coding" title="Warped linear predictive coding">WLPC</a></li></ul></li>
<li><a href="Modified_discrete_cosine_transform" title="Modified discrete cosine transform">MDCT</a></li>
<li><a href="Psychoacoustics" title="Psychoacoustics">Psychoacoustic model</a></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Image_compression" title="Image compression">Image</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chroma_subsampling" title="Chroma subsampling">Chroma subsampling</a></li>
<li><a href="Coding_tree_unit" title="Coding tree unit">Coding tree unit</a></li>
<li><a href="Color_space" title="Color space">Color space</a></li>
<li><a href="Compression_artifact" title="Compression artifact">Compression artifact</a></li>
<li><a href="Image_resolution" title="Image resolution">Image resolution</a></li>
<li><a href="Macroblock" title="Macroblock">Macroblock</a></li>
<li><a href="Pixel" title="Pixel">Pixel</a></li>
<li><a href="Peak_signal-to-noise_ratio" title="Peak signal-to-noise ratio">PSNR</a></li>
<li><a href="Quantization_(image_processing)" title="Quantization (image processing)">Quantization</a></li>
<li><a href="Standard_test_image" title="Standard test image">Standard test image</a></li>
<li><a href="Texture_compression" title="Texture compression">Texture compression</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Methods</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Chain_code" title="Chain code">Chain code</a></li>
<li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Deflate" title="Deflate">Deflate</a></li>
<li><a href="Fractal_compression" title="Fractal compression">Fractal</a></li>
<li><a href="Karhunen%E2%80%93Lo%C3%A8ve_theorem" class="mw-redirect" title="Karhunen–Loève theorem">KLT</a></li>
<li><a href="Pyramid_(image_processing)" title="Pyramid (image processing)">LP</a></li>
<li><a href="Run-length_encoding" title="Run-length encoding">RLE</a></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li>
<li><a href="Embedded_zerotrees_of_wavelet_transforms" title="Embedded zerotrees of wavelet transforms">EZW</a></li>
<li><a href="Set_partitioning_in_hierarchical_trees" title="Set partitioning in hierarchical trees">SPIHT</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Data_compression#Video" title="Data compression">Video</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em"></div><table class="nowraplinks navbox-subgroup" style="border-spacing:0"><tbody><tr><th scope="row" class="navbox-group" style="width:1%">Concepts</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Bit_rate" title="Bit rate">Bit rate</a>
<ul><li><a href="Average_bitrate" title="Average bitrate">ABR</a></li>
<li><a href="Constant_bitrate" title="Constant bitrate">CBR</a></li>
<li><a href="Variable_bitrate" title="Variable bitrate">VBR</a></li></ul></li>
<li><a href="Display_resolution" title="Display resolution">Display resolution</a></li>
<li><a href="Film_frame" title="Film frame">Frame</a></li>
<li><a href="Frame_rate" title="Frame rate">Frame rate</a></li>
<li><a href="Video_compression_picture_types" title="Video compression picture types">Frame types</a></li>
<li><a href="Interlaced_video" title="Interlaced video">Interlace</a></li>
<li><a href="Video#Characteristics_of_video_streams" title="Video">Video characteristics</a></li>
<li><a href="Video_quality" title="Video quality">Video quality</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Video_codec" title="Video codec">Codec</a><br>parts</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Discrete_cosine_transform" title="Discrete cosine transform">DCT</a></li>
<li><a href="Differential_pulse-code_modulation" title="Differential pulse-code modulation">DPCM</a></li>
<li><a href="Deblocking_filter" title="Deblocking filter">Deblocking filter</a></li>
<li><a href="Lapped_transform" title="Lapped transform">Lapped transform</a></li>
<li>Motion
<ul><li><a href="Motion_compensation" title="Motion compensation">Compensation</a></li>
<li><a href="Motion_estimation" title="Motion estimation">Estimation</a></li>
<li><a href="Motion_vector" class="mw-redirect" title="Motion vector">Vector</a></li></ul></li>
<li><a href="Wavelet_transform" title="Wavelet transform">Wavelet</a>
<ul><li><a href="Daubechies_wavelet" title="Daubechies wavelet">Daubechies</a></li>
<li><a href="Discrete_wavelet_transform" title="Discrete wavelet transform">DWT</a></li></ul></li></ul>
</div></td></tr></tbody></table><div></div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Information_theory" title="Information theory">Theory</a></th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Compressed_data_structure" title="Compressed data structure">Compressed data structures</a>
<ul><li><a href="Compressed_suffix_array" title="Compressed suffix array">Compressed suffix array</a></li>
<li><a href="FM-index" title="FM-index">FM-index</a></li></ul></li>
<li><a href="Entropy_(information_theory)" title="Entropy (information theory)">Entropy</a></li>
<li><a href="Information_theory" title="Information theory">Information theory</a>
<ul><li><a href="Timeline_of_information_theory" title="Timeline of information theory">Timeline</a></li></ul></li>
<li><a href="Kolmogorov_complexity" title="Kolmogorov complexity">Kolmogorov complexity</a></li>
<li><a href="Prefix_code" title="Prefix code">Prefix code</a></li>
<li><a href="Quantization_(signal_processing)" title="Quantization (signal processing)">Quantization</a></li>
<li><a href="Rate%E2%80%93distortion_theory" title="Rate–distortion theory">Rate–distortion</a></li>
<li><a href="Redundancy_(information_theory)" title="Redundancy (information theory)">Redundancy</a></li>
<li><a href="Data_compression_symmetry" title="Data compression symmetry">Symmetry</a></li>
<li><a href="Smallest_grammar_problem" title="Smallest grammar problem">Smallest grammar problem</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Community</th><td class="navbox-list-with-group navbox-list navbox-even" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Hutter_Prize" title="Hutter Prize">Hutter Prize</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">People</th><td class="navbox-list-with-group navbox-list navbox-odd" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Mark_Adler" title="Mark Adler">Mark Adler</a></li>
<li><a href="Phil_Katz" title="Phil Katz">Phil Katz</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-05-31" href="https://en.wikipedia.org/wiki/?title=Unary_coding&oldid=1293263079">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>